<?php
/**
 * Created by IntelliJ IDEA.
 * User: keke
 * Date: 18-10-27
 * Time: 上午11:43
 */
require_once "../lib/common.php";
require_once "../congfig/config.php";

$id = $_GET['uid'];
$sql  = "select * from puser where uid = '$id'";
$query = $conn->query($sql);
$num=$query->num_rows;
if($num>=1){
    exit(jsoncall(-1,"该成员有项目"));
}
$sql = "select * from proinfor where teacher = '$id'";
$query = $conn->query($sql);
$num=$query->num_rows;
if($num>=1){
    exit(jsoncall(-1,"该成员有项目"));
}
$sql = "select * from userinfor where uid = '$id'";
$query = $conn->query($sql);
$result = $query->fetch_array();
if ($result['uid'] === $id) {
    $sql = "DELETE FROM userinfor WHERE  uid = '$id'";
    $query = $conn->query($sql);
}

$sql = "DELETE FROM users where uid = '$id'";
$query = $conn->query($sql);
if ($query) {
    exit (jsoncall(1, "删除用户成功"));
} else {
    exit (jsoncall(-1, "删除用户失败"));
}